package com.bana.fvs.app.module.detaile;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.bana.fvs.R;
import com.bana.fvs.app.base.BaseActivity;
import com.bana.fvs.app.main.entity.FogControllerItem;
import com.bana.fvs.app.main.entity.FogZoneListItemBean;
import com.bana.fvs.app.view.TextImageLayout;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by wei on 2018/4/1.
 * 雾灯列表
 */

public class FogLampStateActivity extends BaseActivity {

    private static String EXTRA_WDZT = "wdzt";
    @BindView(R.id.tl_foglight_kzqmc)
    TextImageLayout kzqmc;
    @BindView(R.id.tl_foglight_kzy)
    TextImageLayout kzy;
    @BindView(R.id.tl_foglight_wdzt)
    TextImageLayout wdzt;
    @BindView(R.id.tl_foglight_ld)
    TextImageLayout tlLd;
    @BindView(R.id.tl_foglight_pl)
    TextImageLayout tlPl;
    @BindView(R.id.tl_foglight_zkb)
    TextImageLayout tlZkb;
    @BindView(R.id.tl_foglight_dzs)
    TextImageLayout tlDzs;
    @BindView(R.id.tl_foglight_lddj)
    TextImageLayout tlLddj;
    @BindView(R.id.tl_foglight_ldsc)
    TextImageLayout tlLdsc;
    @BindView(R.id.tl_foglight_mdsc)
    TextImageLayout tlMdsc;
    @BindView(R.id.tl_foglight_hdys)
    TextImageLayout tlHdys;
    @BindView(R.id.tl_foglight_mqys)
    TextImageLayout tlMqys;
    @BindView(R.id.tl_foglight_hsjsdsl)
    TextImageLayout tlHsjsdsl;

//    private FogZoneListItemBean fogZone;
    private FogControllerItem fogZone;

//    public static void startAction(Context context, FogZoneListItemBean fogZone) {
//        Intent intent = new Intent(context, FogLampStateActivity.class);
//        intent.putExtra(EXTRA_WDZT, fogZone);
//        context.startActivity(intent);
//    }
    public static void startAction(Context context, FogControllerItem fogZone) {
        Intent intent = new Intent(context, FogLampStateActivity.class);
        intent.putExtra(EXTRA_WDZT, fogZone);
        context.startActivity(intent);
    }

    @Override
    public int setLayout() {
        return R.layout.activity_fog_lamp_state;
    }

    @Override
    public void setTitle() {
        mBaseTitleBarView.setTitleText("雾灯实际状态");
        mBaseTitleBarView.setLeftTitleGone();
        mBaseTitleBarView.setLeftDrawable(-1);
    }

    /**
     * 处理返回键
     */
    @Override
    public void onTitleLeftPressed() {
        onBackPressed();
    }

    @Override
    public void initWidget() {

//        fogZone = (FogZoneListItemBean) getIntent().getSerializableExtra(EXTRA_WDZT);
        fogZone = (FogControllerItem) getIntent().getSerializableExtra(EXTRA_WDZT);

        if (fogZone == null)
            return;
//        3项必有：控制源，雾灯状态，运行参数
//        红灯黄灯是wdkz=1，2，17.18   3项：亮度等级，闪烁频率，占空比
//        红黄闪是3，19     6项：亮度等级，闪烁频率，占空比，红灯延时，盲区延时，和红色警示灯组数量
//        else关灯
        kzqmc.setRightText(fogZone.getKzqmc());
        kzy.setRightText(fogZone.getKzysm());
        wdzt.setRightText(fogZone.getWdkzsm());


        if(fogZone.getWdkz()==1||fogZone.getWdkz()==2||fogZone.getWdkz()==17||fogZone.getWdkz()==18){
            tlLddj.setVisibility(View.VISIBLE);
            tlPl.setVisibility(View.VISIBLE);
            tlZkb.setVisibility(View.VISIBLE);
        }else if(fogZone.getWdkz()==3||fogZone.getWdkz()==19){
            tlLddj.setVisibility(View.VISIBLE);
            tlPl.setVisibility(View.VISIBLE);
            tlZkb.setVisibility(View.VISIBLE);
            tlHdys.setVisibility(View.VISIBLE);
            tlMqys.setVisibility(View.VISIBLE);
            tlHsjsdsl.setVisibility(View.VISIBLE);
        }

//        if(fogZone.getKzcl()==1){
//        if(fogZone.getWdkz()==1){
//            tlLddj.setVisibility(View.VISIBLE);
//        }else if(fogZone.getWdkz()==2){
//            tlLddj.setVisibility(View.VISIBLE);
//            tlPl.setVisibility(View.VISIBLE);
//            tlZkb.setVisibility(View.VISIBLE);
//        }else if(fogZone.getWdkz()==3){
//            tlLddj.setVisibility(View.VISIBLE);
//            tlPl.setVisibility(View.VISIBLE);
//            tlZkb.setVisibility(View.VISIBLE);
//            tlHdys.setVisibility(View.VISIBLE);
//            tlMqys.setVisibility(View.VISIBLE);
//            tlHsjsdsl.setVisibility(View.VISIBLE);
//        }else if(fogZone.getWdkz()==4){
//            tlLddj.setVisibility(View.VISIBLE);
//            tlPl.setVisibility(View.VISIBLE);
//            tlZkb.setVisibility(View.VISIBLE);
//        }else if(fogZone.getWdkz()==6){
//            tlLd.setVisibility(View.VISIBLE);
//            tlLdsc.setVisibility(View.VISIBLE);
//            tlMdsc.setVisibility(View.VISIBLE);
//            tlHdys.setVisibility(View.VISIBLE);
//            tlMqys.setVisibility(View.VISIBLE);
//            tlHsjsdsl.setVisibility(View.VISIBLE);
//        }


        tlLd.setRightText("" + fogZone.getWdld());
        tlPl.setRightText(fogZone.getSsplsm());
        tlZkb.setRightText(fogZone.getZkbsm());
        tlDzs.setRightText(fogZone.getHsjsdzsl() + "");
        tlLddj.setRightText(fogZone.getWdlddj()+"");
        tlLdsc.setRightText(fogZone.getLdsc()+"ms");
        tlMdsc.setRightText(fogZone.getMdsc()+"ms");
        tlHdys.setRightText(fogZone.getHdys()+"s");
        tlMqys.setRightText(fogZone.getMqys()+"s");
        tlHsjsdsl.setRightText(fogZone.getHsjsdzsl()+"个");

    }


    @Override
    public void widgetClick(View v) {

    }

    @Override
    protected void initPresenter() {

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }
}
